import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:get/get.dart';

import 'state.dart';

class GongDansLogic extends GetxController {
  final state = GongDansState();

  @override
  void onInit() async {
    super.onInit();
    print(Get.arguments["tmlId"]);

    var response = await Dio().post(
      'https://fwqa.zrhsh.com/openInterface/getOrderOperation.jhtml',
      data: {
        "appSecret": 123456,
        "companyName": '中燃慧生活新零售系统',
        "orderNos": [Get.arguments["tmlId"]]
      },
      options: Options(
        headers: {
          'content-type': 'application/json' // 默认值
        },
      ),
    );
    var data = jsonDecode(response.data);
    if (data["result_flag"] != 0) {
      state.orderList = [];
    } else {
      if(data["orderList"]==null || data["orderList"][0]==null || data["orderList"][0]['data']==null){
        state.orderList = [];
      }else {
        state.orderList = data["orderList"][0]['data'];
      }
    }
    update();

    print(data);
  }
}
